package com.twu.biblioteca.main;

import com.twu.biblioteca.entity.Book;
import com.twu.biblioteca.entity.Movie;
import com.twu.biblioteca.entity.User;
import com.twu.biblioteca.provider.DataProvider;

import java.util.ArrayList;

public class Library {

    public static Library build()
    {
        Library bangalorePublicLibrary = new Library();
        bangalorePublicLibrary.setupLibraryWithInitialBooks();
        return bangalorePublicLibrary;
    }

    public boolean addBook(Book newBook)
    {
        return books.add(newBook);
    }

    public ArrayList<Book> getAllBooks()
    {
        return books;
    }

    public ArrayList<Movie> getAllMovies()
    {
        return movies;
    }

    public ArrayList<User> getAllUsers()
    {
        return users;
    }


    public Librarian getLibrarian()
    {
        return librarian;
    }

    private Library()
    {

    }
    private void setupLibraryWithInitialBooks()
    {
        DataProvider.loadAvailableBooks(books);
        DataProvider.loadAvailableMovies(movies);
        DataProvider.loadAvailableUsers(users);
    }

    private Librarian librarian = new Librarian(this);
    private ArrayList<Book> books = new ArrayList<Book>();
    private ArrayList<Movie> movies = new ArrayList<Movie>();
    private ArrayList<User> users = new ArrayList<User>();
}
